import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_study_app/module/archives_statistics/archives_statistics_router.dart';
import 'package:flutter_study_app/module/case_clear/case_clear_router.dart';
import 'package:flutter_study_app/module/home_page.dart';
import 'package:flutter_study_app/module/online_lend/online_lend_router.dart';
import 'package:flutter_study_app/module/special_region/storage_special_region_router.dart';
import 'package:flutter_study_app/module/statistics/statistics_router.dart';
import 'package:flutter_study_app/module/visit/visit_router.dart';
import 'package:flutter_study_app/module/visit/page/visit_zone_page.dart';
import 'package:intl/date_symbol_data_local.dart';

import 'app/router/routers.dart';

void main() {
  //初始化路由
  initAppRouters();
  //初始化Formatter
  initializeDateFormatting();
  runApp(MyApp());
  if (Platform.isAndroid) {
    SystemChrome.setSystemUIOverlayStyle(
        SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  }
}

void initAppRouters() {
  Routers.initRouters([
    VisitRouter(),
    StatisticsRouter(),
    CaseClearRouter(),
    ArchivesStatisticsRouter(),
    OnlineLendRouter(),
    StorageSpecialRegionRouter(),
  ]);
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: Size(360, 690),
      builder: () {
        return MaterialApp(
          title: 'FlutterStudyApp',
          theme: ThemeData(
            // This is the theme of your application.
            //primarySwatch: Colors.blue,
            primaryColor: Colors.white,
          ),
          onGenerateRoute: Routers.router.generator,
          builder: (context, child) {
            return FlutterEasyLoading(
                child: Scaffold(
              resizeToAvoidBottomInset: false,
              body: child,
            ));
          },
          home: HomePage(),
        );
      },
    );
  }
}
